package com.pwt.controller.crustallus;

import com.pwt.entity.FilterUnit;
import com.pwt.model.ShiftModel;
import com.pwt.service.FilterUnitService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/10/11
 */
@RestController
@Tag(name = "过滤器")
public class FilterController {

    private FilterUnitService filterUnitService;

    public FilterController(FilterUnitService filterUnitService) {
        this.filterUnitService = filterUnitService;
    }

    @PostMapping("filter")
    @Operation(description = "添加修改过滤器",summary = "添加修改过滤器")
    public FilterUnit update(@RequestBody FilterUnit filterUnit){
        return this.filterUnitService.update(filterUnit);
    }

    @GetMapping("filter")
    @Operation(description = "查询个人配置过滤器",summary = "查询个人配置过滤器")
    public FilterUnit getFilterUnit(){
        return this.filterUnitService.getFilterUnit();
    }

    @GetMapping("shift")
    @Operation(description = "获取班次时间",summary = "获取班次时间")
    @Parameters({
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss"),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss")
    })
    public List<ShiftModel> getShiftList(String startTime, String endTime) throws ParseException {
        return this.filterUnitService.getShiftList(startTime,endTime);
    }
}
